/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class PVTChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private float[] pvt;
/*     */   private float[] pvtMA_parm1;
/*  21 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  23 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private JTextField parm1TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  31 */   private DecimalFormat df = new DecimalFormat("0.00E00");
/*     */ 
/*  33 */   public String trend = "";
/*     */   public PVTChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 501 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 502 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 503 */   private Line2D.Double refL1 = new Line2D.Double();
/* 504 */   private Line2D.Double refL2 = new Line2D.Double();
/* 505 */   private Line2D.Double gridY = new Line2D.Double();
/* 506 */   private Line2D.Double gridX = new Line2D.Double();
/* 507 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 508 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 513 */   private Line2D.Double l1 = new Line2D.Double();
/* 514 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 516 */   private Line2D.Double uA = new Line2D.Double();
/* 517 */   private Line2D.Double lA = new Line2D.Double();
/* 518 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public PVTChart(SymQuotes paramSymQuotes, int paramInt)
/*     */   {
/*  39 */     this.sq = paramSymQuotes;
/*  40 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  42 */     this.pvt = new float[paramSymQuotes.count];
/*  43 */     this.pvtMA_parm1 = new float[paramSymQuotes.count];
/*     */ 
/*  45 */     this.parm1 = paramInt;
/*     */ 
/*  47 */     if (this.noOfDays == 150)
/*  48 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  50 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  52 */     setBackground(Color.black);
/*  53 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  55 */     pvtFinder();
/*     */ 
/*  57 */     if (paramInt < paramSymQuotes.count) {
/*  58 */       pvtMA_parm1Finder();
/*     */     }
/*  60 */     findMinMax();
/*  61 */     addMouseMotionListener(this);
/*     */ 
/*  63 */     if (this.pvt[(paramSymQuotes.count - 1)] >= this.pvtMA_parm1[(paramSymQuotes.count - 1)])
/*  64 */       this.trend = "Bullish";
/*     */     else {
/*  66 */       this.trend = "Bearish";
/*     */     }
/*  68 */     this.ep = new PVTChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/*  75 */     if (this.pvt[paramInt] >= this.pvtMA_parm1[paramInt]) {
/*  76 */       return 1;
/*     */     }
/*  78 */     return 0;
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  85 */     this.noOfDays = paramInt;
/*     */ 
/*  87 */     if (paramInt == 150)
/*  88 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  90 */       this.stickWidth = (1.5D * this.xScale);
/*  91 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/*  98 */     this.sq = paramSymQuotes;
/*  99 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 101 */     this.pvt = new float[paramSymQuotes.count];
/* 102 */     this.pvtMA_parm1 = new float[paramSymQuotes.count];
/*     */ 
/* 104 */     if (this.noOfDays == 150)
/* 105 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 107 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 109 */     pvtFinder();
/*     */ 
/* 111 */     if (this.parm1 < paramSymQuotes.count) {
/* 112 */       pvtMA_parm1Finder();
/*     */     }
/* 114 */     findMinMax();
/*     */ 
/* 116 */     if (this.pvt[(paramSymQuotes.count - 1)] >= this.pvtMA_parm1[(paramSymQuotes.count - 1)])
/* 117 */       this.trend = "Bullish";
/*     */     else {
/* 119 */       this.trend = "Bearish";
/*     */     }
/* 121 */     repaint();
/* 122 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 129 */     Arrays.fill(this.pvt, 0.0F);
/* 130 */     Arrays.fill(this.pvtMA_parm1, 0.0F);
/*     */ 
/* 132 */     pvtFinder();
/*     */ 
/* 134 */     if (this.parm1 < this.sq.count) {
/* 135 */       pvtMA_parm1Finder();
/*     */     }
/* 137 */     findMinMax();
/*     */ 
/* 139 */     if (this.pvt[(this.sq.count - 1)] >= this.pvtMA_parm1[(this.sq.count - 1)])
/* 140 */       this.trend = "Bullish";
/*     */     else {
/* 142 */       this.trend = "Bearish";
/*     */     }
/* 144 */     repaint();
/* 145 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 153 */     int j = 1;
/* 154 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 156 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 158 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 160 */         j = this.sq.count - 1 - i;
/* 161 */         this.m = ("( " + (String)this.sq.date.get(j) + ", PVT:" + this.df.format(this.pvt[j]) + "  PVT MA[" + this.parm1 + "]:" + this.df.format(this.pvtMA_parm1[j]) + " )");
/*     */ 
/* 163 */         this.mX = paramMouseEvent.getX();
/* 164 */         this.mY = paramMouseEvent.getY();
/* 165 */         repaint();
/* 166 */         return;
/*     */       }
/*     */ 
/* 170 */       this.m = "";
/*     */ 
/* 172 */       repaint();
/* 173 */       return;
/*     */     }
/*     */ 
/* 177 */     this.m = "";
/* 178 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 191 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 193 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 194 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 196 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void pvtFinder()
/*     */   {
/* 203 */     this.pvt[0] = ((Integer)this.sq.qty.get(0)).intValue();
/*     */ 
/* 205 */     for (int i = 1; i < this.sq.count; i++)
/*     */     {
/* 207 */       this.pvt[i] = ((((Float)this.sq.close.get(i)).floatValue() - ((Float)this.sq.close.get(i - 1)).floatValue()) / ((Float)this.sq.close.get(i - 1)).floatValue() * ((Integer)this.sq.qty.get(i)).intValue() + this.pvt[(i - 1)]);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void pvtMA_parm1Finder()
/*     */   {
/* 216 */     for (int i = 0; i < this.parm1; i++) {
/* 217 */       this.pvtMA_parm1[i] = 0.0F;
/*     */     }
/* 219 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 221 */       float f = 0.0F;
/* 222 */       for (int j = i; j > i - this.parm1; j--)
/*     */       {
/* 224 */         f += this.pvt[j];
/*     */       }
/*     */ 
/* 227 */       this.pvtMA_parm1[i] = (f / this.parm1);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void findMinMax()
/*     */   {
/* 236 */     int i = 1;
/* 237 */     this.minVal = this.pvt[(this.sq.count - 1)];
/* 238 */     this.maxVal = this.pvt[(this.sq.count - 1)];
/*     */ 
/* 240 */     for (int j = this.sq.count - 1; j >= 1; j--)
/*     */     {
/* 242 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 245 */       if (this.minVal > this.pvt[j]) {
/* 246 */         this.minVal = this.pvt[j];
/*     */       }
/* 248 */       if (this.maxVal < this.pvt[j]) {
/* 249 */         this.maxVal = this.pvt[j];
/*     */       }
/* 251 */       i += 1;
/*     */     }
/*     */ 
/* 255 */     i = 1;
/* 256 */     for (int j = this.sq.count - 1; j >= this.parm1; j--)
/*     */     {
/* 258 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 261 */       if (this.minVal > this.pvtMA_parm1[j]) {
/* 262 */         this.minVal = this.pvtMA_parm1[j];
/*     */       }
/* 264 */       if (this.maxVal < this.pvtMA_parm1[j]) {
/* 265 */         this.maxVal = this.pvtMA_parm1[j];
/*     */       }
/* 267 */       i += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt)
/*     */   {
/* 277 */     this.parm1 = paramInt;
/*     */ 
/* 279 */     pvtFinder();
/* 280 */     pvtMA_parm1Finder();
/* 281 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public Box getPVTBox(boolean paramBoolean)
/*     */   {
/* 288 */     Box localBox = Box.createHorizontalBox();
/* 289 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("PVT");
/*     */ 
/* 291 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 292 */     this.parm1TF.setFont(this.ssp10);
/* 293 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 295 */     JLabel localJLabel1 = new JLabel("PVT MA[");
/* 296 */     JLabel localJLabel2 = new JLabel("]     ");
/*     */ 
/* 298 */     localJLabel1.setFont(this.ssp10);
/* 299 */     localJLabel2.setFont(this.ssp10);
/*     */ 
/* 301 */     localBox.add(localJLabel1);
/* 302 */     localBox.add(this.parm1TF);
/* 303 */     localBox.add(localJLabel2);
/*     */ 
/* 305 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 307 */     if (paramBoolean) {
/* 308 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 310 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 317 */     JFrame localJFrame = new JFrame();
/* 318 */     this.chgParmDialog = new JDialog(localJFrame, "Change PVT Parameters", true);
/* 319 */     Box localBox1 = Box.createVerticalBox();
/* 320 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 322 */     this.chgParmOk = new JButton("OK");
/* 323 */     this.chgParmOk.setFont(this.ssp10);
/* 324 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 325 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 327 */     this.chgParmCancel = new JButton("Cancel");
/* 328 */     this.chgParmCancel.setFont(this.ssp10);
/* 329 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 330 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 332 */     this.defaultParms = new JButton("Default");
/* 333 */     this.defaultParms.setFont(this.ssp10);
/* 334 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 335 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 336 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 338 */     localBox2.add(Box.createHorizontalGlue());
/* 339 */     localBox2.add(this.chgParmOk);
/* 340 */     localBox2.add(Box.createHorizontalStrut(5));
/* 341 */     localBox2.add(this.chgParmCancel);
/* 342 */     localBox2.add(Box.createHorizontalStrut(5));
/* 343 */     localBox2.add(this.defaultParms);
/* 344 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 346 */     localBox1.add(getPVTBox(true));
/* 347 */     localBox1.add(localBox2);
/*     */ 
/* 349 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 350 */     this.chgParmDialog.setSize(250, 100);
/* 351 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 352 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 359 */     int i = this.parm1;
/*     */     try
/*     */     {
/* 363 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 369 */       JOptionPane.showMessageDialog(null, "Error in PVT parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 372 */       this.parm1TF.setText("" + this.parm1);
/*     */ 
/* 374 */       return false;
/*     */     }
/*     */ 
/* 378 */     if (i > 200)
/*     */     {
/* 380 */       JOptionPane.showMessageDialog(null, "Error in PVT parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 383 */       this.parm1TF.setText("" + this.parm1);
/*     */ 
/* 385 */       return false;
/*     */     }
/*     */ 
/* 389 */     if (i < 2)
/*     */     {
/* 391 */       JOptionPane.showMessageDialog(null, "Error in PVT parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 394 */       this.parm1TF.setText("" + this.parm1);
/*     */ 
/* 396 */       return false;
/*     */     }
/*     */ 
/* 400 */     this.parm1 = i;
/*     */ 
/* 402 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 409 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 411 */       if (!validateParm()) {
/* 412 */         return;
/*     */       }
/* 414 */       redrawChart();
/* 415 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 419 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 421 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 425 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 427 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 436 */     this.parm1TF.setText("12");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 443 */     if (paramBoolean)
/* 444 */       this.yScale += 0.2F;
/* 445 */     else if (this.yScale >= 1.2F) {
/* 446 */       this.yScale -= 0.2F;
/*     */     }
/* 448 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 455 */     if (paramBoolean)
/* 456 */       this.xScale += 0.2F;
/* 457 */     else if (this.xScale >= 1.2F) {
/* 458 */       this.xScale -= 0.2F;
/*     */     }
/* 460 */     if (this.noOfDays == 150)
/* 461 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 463 */       this.stickWidth = (1.5D * this.xScale);
/* 464 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 471 */     this.yScale = 1.0F;
/* 472 */     this.xScale = 1.0F;
/* 473 */     if (this.noOfDays == 150)
/* 474 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 476 */       this.stickWidth = (1.5D * this.xScale);
/* 477 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 484 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 491 */     clear(paramGraphics);
/* 492 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 493 */     drawChart(localGraphics2D);
/* 494 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 523 */     this.refY = 10.0D;
/* 524 */     this.refX = 50.0D;
/* 525 */     setFont(this.ssp10);
/* 526 */     String str = "Price & Volume Trend";
/* 527 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 528 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 530 */     str = "PVT";
/* 531 */     paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 532 */     paramGraphics2D.drawString(str, 165, 10);
/*     */ 
/* 534 */     str = "PVT MA[" + this.parm1 + "]";
/* 535 */     paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 536 */     paramGraphics2D.drawString(str, 195, 10);
/*     */ 
/* 539 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 540 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 541 */     paramGraphics2D.setPaint(Color.white);
/* 542 */     paramGraphics2D.draw(this.refL1);
/* 543 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 545 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 547 */       this.refX += 50.0F * this.xScale;
/* 548 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 549 */       paramGraphics2D.setPaint(Color.darkGray);
/* 550 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 554 */     for (i = 0; i < 11; i++)
/*     */     {
/* 556 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/*     */ 
/* 558 */       if (this.maxVal > 99999.0F)
/* 559 */         str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/*     */       else {
/* 561 */         str = "" + (int)(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/*     */       }
/* 563 */       paramGraphics2D.setPaint(Color.lightGray);
/* 564 */       paramGraphics2D.drawString(str, 5, (int)this.refY);
/* 565 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 567 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 568 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 569 */       paramGraphics2D.setPaint(Color.white);
/* 570 */       paramGraphics2D.draw(this.yrefL1);
/* 571 */       paramGraphics2D.draw(this.yrefL2);
/* 572 */       paramGraphics2D.setPaint(Color.darkGray);
/* 573 */       paramGraphics2D.draw(this.gridX);
/* 574 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 578 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 579 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 580 */     this.dateRef = (this.sq.count - 1);
/* 581 */     this.daysRef = 1;
/*     */ 
/* 584 */     for (i = this.sq.count - 1; i > 1; i--)
/*     */     {
/* 586 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 588 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 591 */       if (i > this.parm1)
/*     */       {
/* 593 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.pvtMA_parm1[i] - this.minVal) * this.yfactor);
/* 594 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.pvtMA_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 596 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 597 */         paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 598 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 602 */       if (i > 1)
/*     */       {
/* 604 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.pvt[i] - this.minVal) * this.yfactor);
/* 605 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.pvt[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 607 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 608 */         paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 609 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 613 */       if ((i > this.parm1) && (this.pvt[i] - this.pvtMA_parm1[i] >= 0.0F) && (this.pvt[(i - 1)] - this.pvtMA_parm1[(i - 1)] < 0.0F))
/*     */       {
/* 615 */         this.x1 = this.startPointX;
/* 616 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 617 */         this.y1 = this.p1Y;
/* 618 */         this.y2 = this.p2Y;
/* 619 */         this.u1 = this.x1;
/* 620 */         this.u2 = this.x2;
/* 621 */         this.v1 = this.p11Y;
/* 622 */         this.v2 = this.p22Y;
/*     */ 
/* 624 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 625 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 627 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 628 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 630 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 631 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 633 */         paramGraphics2D.setPaint(Color.green);
/* 634 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 635 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 636 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 637 */         paramGraphics2D.draw(this.uA);
/* 638 */         paramGraphics2D.draw(this.lA);
/* 639 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 643 */       if ((i > this.parm1) && (this.pvt[i] - this.pvtMA_parm1[i] < 0.0F) && (this.pvt[(i - 1)] - this.pvtMA_parm1[(i - 1)] > 0.0F))
/*     */       {
/* 645 */         this.x1 = this.startPointX;
/* 646 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 647 */         this.y1 = this.p1Y;
/* 648 */         this.y2 = this.p2Y;
/* 649 */         this.u1 = this.x1;
/* 650 */         this.u2 = this.x2;
/* 651 */         this.v1 = this.p11Y;
/* 652 */         this.v2 = this.p22Y;
/*     */ 
/* 654 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 655 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 657 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 658 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 660 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 661 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 663 */         paramGraphics2D.setPaint(Color.red);
/* 664 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 665 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 666 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 667 */         paramGraphics2D.draw(this.uA);
/* 668 */         paramGraphics2D.draw(this.lA);
/* 669 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 673 */       if (this.dateRef == i)
/*     */       {
/* 675 */         paramGraphics2D.setFont(this.ssp9);
/* 676 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 677 */         if (this.pvt[i] >= this.pvtMA_parm1[i])
/* 678 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 680 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 682 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 683 */         if (this.noOfDays == 150)
/* 684 */           this.dateRef -= 10;
/*     */         else
/* 686 */           this.dateRef -= 20;
/* 687 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 691 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 692 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 756 */     FileDownloader localFileDownloader = new FileDownloader();
/* 757 */     localFileDownloader.downloadFiles();
/* 758 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 760 */     PVTChart localPVTChart = new PVTChart(localSymQuotes, 12);
/*     */ 
/* 762 */     JFrame localJFrame = new JFrame("Test");
/* 763 */     localJFrame.setDefaultCloseOperation(3);
/* 764 */     localJFrame.getContentPane().add(localPVTChart);
/* 765 */     localJFrame.pack();
/* 766 */     localJFrame.setSize(850, 175);
/* 767 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel pvtL;
/*     */     private JLabel pvtMaL;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 704 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 705 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 709 */       this.title = new JLabel("PVT");
/* 710 */       this.pvtL = new JLabel("PVT: " + PVTChart.this.df.format(PVTChart.this.pvt[(PVTChart.this.sq.count - 1)]));
/* 711 */       this.pvtMaL = new JLabel("PVT MA[" + PVTChart.this.parm1 + "]: " + PVTChart.this.df.format(PVTChart.this.pvtMA_parm1[(PVTChart.this.sq.count - 1)]));
/*     */ 
/* 713 */       this.trendL = new JLabel("Trend: " + PVTChart.this.trend);
/* 714 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/pvt.htm", "Help on PVT");
/*     */ 
/* 716 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 718 */       this.pvtL.setFont(this.valuesF);
/* 719 */       this.pvtMaL.setFont(this.valuesF);
/* 720 */       this.trendL.setFont(this.valuesF);
/*     */ 
/* 722 */       this.buttonsPanel.add(this.chb);
/* 723 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 724 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 726 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 728 */       add(this.title);
/* 729 */       add(this.pvtL);
/* 730 */       add(this.pvtMaL);
/* 731 */       add(new JLabel(" "));
/* 732 */       add(this.trendL);
/* 733 */       add(this.buttonsPanel);
/* 734 */       add(Box.createVerticalGlue());
/*     */ 
/* 736 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 743 */       this.pvtL.setText("PVT: " + PVTChart.this.df.format(PVTChart.this.pvt[(PVTChart.this.sq.count - 1)]));
/* 744 */       this.pvtMaL.setText("PVT MA[" + PVTChart.this.parm1 + "]: " + PVTChart.this.df.format(PVTChart.this.pvtMA_parm1[(PVTChart.this.sq.count - 1)]));
/* 745 */       this.trendL.setText("Trend: " + PVTChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     PVTChart
 * JD-Core Version:    0.6.0
 */